﻿#region Copyright and Licensing Notice
// Copyright (C) 2011 Steven Bosnick
// 
// This program is open source software; you can redistribute it 
// and/or modifiy it under the terms of the Eclipse Public License,
// version 1.0.
// 
// This program is distributed in the hope that it will be useful, 
// but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A 
// PARTICULAR PURPOSE. See the Eclipse Public License for more
// details.
// 
// You should have received a copy of the Eclipse Public License 
// along with this program; if not, you can find a copy at
// "http://www.opensource.org/licenses/eclipse-1.0.php".
#endregion
namespace BitwiseOre.SharedMemory.Core.Primatives
{
    internal struct ConnectionBufferHeader
    {
        private const uint MagicCookie = 0x8A55BC33;
        private const uint Version = 1;

        private readonly uint _cookie;
        private readonly uint _version;
        private readonly int _count;
        private readonly int _bufferSize;

        public ConnectionBufferHeader(int count, int bufferSize)
        {
            _count = count;
            _bufferSize = bufferSize;
            _cookie = MagicCookie;
            _version = Version;
        }

        public int BufferSize
        {
            get { return _bufferSize; }
        }

        public int Count
        {
            get { return _count; }
        }

        public bool Verify()
        {
            return (_cookie == MagicCookie && _version == Version);
        }

    }
}